package com.xc.quickstart.common.bean;

import cn.hutool.core.date.DateUtil;
import com.xc.quickstart.common.context.EnvironmentContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

@Component
@Slf4j
public class BootCompleteRunner implements CommandLineRunner {
    @Autowired
    private Environment env;



    private final static Set<String> ENVIRONMENT_SET = new HashSet<String>() {{
        add(EnvironmentContext.STAGE);
        add(EnvironmentContext.PROD);
    }};

    @Override
    public void run(String... args) {
        String msg = String.format("【%s】【%s】【%s】系统启动成功..."
                , env.getProperty("spring.profiles.active")
                , env.getProperty("spring.application.name")
                , DateUtil.formatDateTime(new Date()));

        log.info(msg);

        if (ENVIRONMENT_SET.contains(env.getProperty("spring.profiles.active"))) {

        }
    }
}
